package cn.thornbird.orgsync.vo.record;

import cn.thornbird.orgsync.entity.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class SimpleUserRecord extends Record<User> {

    public static final String USERNAME_REG_EXP = "^[A-Za-z][A-Za-z\\d_-]{0,14}[A-Za-z\\d]{1}$";

    public static final String EMAIL_REG_EXP = "^$|^([A-Za-z0-9_\\-.\\u4e00-\\u9fa5])+@([A-Za-z0-9_\\-.])+.([A-Za-z]{2,8})$";

    public static final String MOBILE_REG_EXP = "^1[3-9]\\d{9}$";

    public static final String TELEPHONE_REG_EXP = "^$|^0\\d{2,3}-\\d{7,8}$|^0\\d{2,3}-\\d{7,8}-\\d{1,4}$";

    public static final String PASSWORD_REG_EXP = "(?=.*[0-9])(?=.*[a-zA-Z!@_#$%^&*()\\-+=,.?]).{6,16}$";

    @NotBlank(message = "用户名不能为空")
    @Pattern(regexp = USERNAME_REG_EXP, message = "用户名不符合规则")
    private String username;

    @Size(max = 32, message = "姓名长度不符合要求")
    private String name;

    @Size(max = 32, message = "公司长度不符合要求")
    private String company;

    @Size(max = 32, message = "部门长度不符合要求")
    private String department;

    @Size(max = 32, message = "职位长度不符合要求")
    private String title;

    @Pattern(regexp = EMAIL_REG_EXP, message = "Email格式不正确")
    @Size(max = 64, message = "Email长度不符合要求")
    private String email;

    @NotBlank(message = "手机不能为空")
    @Pattern(regexp = MOBILE_REG_EXP, message = "手机格式不正确")
    @Size(max = 32, message = "手机长度不符合要求")
    private String mobile;

    @Pattern(regexp = TELEPHONE_REG_EXP, message = "电话格式不正确")
    @Size(max = 32, message = "电话长度不符合要求")
    private String telephone;

    @Size(max = 128, message = "头像长度不符合要求")
    private String avatar;

    private String avatarId;

}
